//
//  ACNumberView.m
//  CP20180523
//
//  Created by apple on 2018/5/25.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ACNumberView.h"

@implementation ACNumberView


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (IBAction)deleteNumberAction:(id)sender {
    [self removeFromSuperview];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"reloadRandomNumberBox" object:nil];
}

-(void)getNumber:(NSArray*)numberArr{
    
    self.numberLabel.text = [numberArr componentsJoinedByString:@"  "];
    
    NSInteger total = 0;
    for (int i =0;i<[numberArr count]; i++) {
        total += [numberArr[i] integerValue];
    }
    self.totalLabel.text = [NSString stringWithFormat:@"%ld",total];
    self.spanLabel.text = [NSString stringWithFormat:@"%ld",[numberArr[4] integerValue]-[numberArr[0] integerValue]];
    
    NSMutableSet* numberSet = [[NSMutableSet alloc] initWithCapacity:0];
    for (int i = 0; i<[numberArr count]; i++) {
        for (int j = i+1; j<[numberArr count]; j++) {
            NSInteger Difference = [numberArr[i] integerValue]-[numberArr[j] integerValue];
            [numberSet addObject:@(ABS(Difference))];
        }
    }
    self.ACValueLabel.text = [NSString stringWithFormat:@"%ld",[numberSet count]-4];
}

@end
